home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / os2 / adaptor.zip / ADAPT.ZIP / adaptor / examples / dalib / generic / nodsnd1.f < prev    next >
Encoding:
Text File  |  1993-04-28  |  848 b   |  35 lines

  1.       program nodesend1
  2.  
  3. c     Note: This program should only demonstrate the functionality, but
  4. c           it is a very inefficient program
  5.  
  6.       real ra (:), a(:), s
  7. cmf$  layout ra(:serial)
  8.  
  9.       integer i, N
  10.  
  11.       print *, 'Input size N = '
  12.       read *, N
  13.  
  14.       allocate (a(N), ra(N))
  15.  
  16.       do i = 1, N
  17.          a(i) = i     ! initialize the distributed array
  18.       end do
  19.  
  20.       do i = 1, N
  21.          x = a(i)     ! node_get, host_get, indeed N broadcasts
  22.          ra(i) = x    ! have_i_value
  23.       end do
  24.  
  25.       s = sum (ra)    ! prove that host has correct values
  26.       print *, 'Result is ', s, ' should be ', N * (N+1) / 2
  27.  
  28.       a = a + ra(N:1:-1)  ! local operation on nodes
  29.       s = sum (a)     ! prove that nodes have correct values
  30.       print *, 'Result is ', s, ' should be ', N * (N+1) 
  31.  
  32.       deallocate (ra, a)
  33.  
  34.       end
  35.